Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
The npm package 'cookiejar' is a utility for handling web cookies in Node.js. It allows for the creation, retrieval, manipulation, and deletion of cookies, making it easier to manage client-side state information across web requests.
Create and manage cookies
This feature allows the creation and management of cookies. The code sample demonstrates how to create a new cookie jar and set a cookie with an expiration date.
const CookieJar = require('cookiejar');
const jar = new CookieJar();
const cookie = jar.setCookie('key=value; expires=Wed, 09 Jun 2021 10:18:14 GMT');
Retrieve cookies
This feature enables the retrieval of cookies based on specific criteria such as domain and path. The code shows how to retrieve a cookie from the jar that matches the specified domain and path.
const CookieJar = require('cookiejar');
const jar = new CookieJar();
jar.setCookie('key=value; path=/; domain=example.com');
const cookie = jar.getCookie('key', {domain: 'example.com', path: '/'});
Parse and serialize cookies
This feature deals with parsing cookies from request headers and serializing them for HTTP headers. The code illustrates how to serialize all cookies in the jar for use in an HTTP request.
const CookieJar = require('cookiejar');
const CookieAccessInfo = CookieJar.CookieAccessInfo;
const jar = new CookieJar();
jar.setCookie('key=value; path=/; domain=example.com');
const serializedCookies = jar.getCookies(CookieAccessInfo.All).toValueString();
Tough-cookie is another popular npm package for handling cookies in Node.js. It offers a robust API for cookie manipulation and parsing, including asynchronous cookie storage, which cookiejar does not support. Tough-cookie is often preferred for more complex cookie handling tasks.
The 'cookie' npm package is simpler and more lightweight compared to cookiejar. It focuses primarily on parsing and serializing cookie headers, without the additional management features like a cookie jar. This makes it suitable for applications that require minimal cookie handling capabilities.
Simple robust cookie library
class to determine matching qualities of a cookie
It turns input into a Cookie (singleton if given a Cookie),
the request_domain
argument is used to default the domain if it is not explicit in the cookie string,
the request_path
argument is used to set the path if it is not explicit in a cookie String.
Explicit domains/paths will cascade, implied domains/paths must exactly match (see http://en.wikipedia.org/wiki/HTTP_cookie#Domain_and_Pat).
String toString()
- the set-cookie: string for this cookieString toValueString()
- the cookie: string for this cookieCookie parse(cookiestr, request_domain, request_path)
- parses the string onto this cookie or a new one if called directlyBoolean matches(access_info)
- returns true if the access_info allows retrieval of this cookieBoolean collidesWith(cookie)
- returns true if the cookies cannot exist in the same space (domain and path match)class to hold numerous cookies from multiple domains correctly
Cookie setCookie(cookie, request_domain, request_path)
- modify (or add if not already-existing) a cookie to the jarCookie[] setCookies(cookiestr_or_list, request_domain, request_path)
- modify (or add if not already-existing) a large number of cookies to the jarCookie getCookie(cookie_name,access_info)
- get a cookie with the name and access_info matchingCookie[] getCookies(access_info)
- grab all cookies matching this access_infoFAQs
simple persistent cookiejar system
The npm package cookiejar receives a total of 3,587,138 weekly downloads. As such, cookiejar popularity was classified as popular.
We found that cookiejar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.